import { Constant } from "../constant";
import { UniHelp } from "../uni-help";
import haoguanjia from "./haoguanjia";
import jiedanbao from "./jiedanbao";
import pindasiji from "./pindasiji";

const appsList = [haoguanjia, jiedanbao, pindasiji];

export namespace AppDeclare {
	/**
	 * 获取当前应用的配置
	 */
	export function getCurrentApp() {
		return appsList.find(item => item.appid === UniHelp.getAccountInfo().miniProgram.appId);
	}

	/**
	 * 获取接单宝配置
	 */
	export function getAppJDBConfig () {
		return appsList.find(item => item.appid === Constant.JDB_APPID);
	}

	/**
	 * 是否为拼哒司机
	 * @returns boolean true:是  false:否
	 */
	export function isPDSJ() {
		return getCurrentApp()?.appid === Constant.PDSJ_APPID;
	}

	/**
	 * 是否为接单宝
	 * @returns boolean true:是  false:否
	 */
	export function isJDB() {
		return getCurrentApp()?.appid === Constant.JDB_APPID;
	}

	/**
	 * 是否为好管家
	 * @returns boolean true:是  false:否
	 */
	export function isHGJ() {
		return getCurrentApp()?.appid === Constant.HGJ_APPID;
	}

	/**
	 * 是否为车队端
	 * @returns boolean true:是  false:否
	 */
	export function isCpMini() {
		return isHGJ();
	}

	/**
	 * 是否为司机端
	 * @returns boolean true:是  false:否
	 */
	export function isDriverMini() {
		return isJDB() || isPDSJ();
	}
}


